package com.example;

import redis.clients.jedis.Jedis;
import org.junit.Test;

import java.util.Set;

public class JedisTest {
    @Test
    public void testJedis(){
        //1.获取连接
        Jedis jedis = new Jedis("localhost",6379);

        //2.输入认证密码（若存在）
        jedis.auth("123456");

        //3.操作
        jedis.set("name","xiaoming");

        jedis.hset("math","xiaohong","90");
        jedis.hset("math", "xiaoli","80");

        String hget = jedis.hget("math", "xiaohong");
        System.out.println(hget);

        Set<String> keys = jedis.keys("*");
        for (String key : keys) {
            System.out.println("key:"+ key);
        }
        //4.关闭连接
        jedis.close();

    }
}
